/**
 * @description 有关于商品的接口+
 */

import request from '@/utils/request'

/**
 * @description 获取商品信息列表
 * @param {Object} data 请求参数
 * @returns {Promise} 商品列表
 */
export const fetchGoodsList = (data) => {
  return request({
    url: '/dealer/pzDealerGoods/selectDealerGoodsByCondition',
    method: 'post',
    data,
  })
}

/**
 * @description 添加或修改商品信息
 * @param {Object} data 请求参数
 * @returns {Promise}
 */
export const saveGoods = (data) => {
  return request({
    url: '/dealer/pzDealerGoods/saveDealerGoods',
    method: 'post',
    data,
  })
}

/**
 * @description 删除商品信息
 * @param {string} id 商品ID
 * @returns {Promise}
 */
export const deleteGoods = (id) => {
  return request({
    url: `/dealer/pzDealerGoods/deleteDealerGoodsById?id=${id}`,
    method: 'post',
  })
}

/**
 * @description 获取商品类别列表
 * @returns {Promise} 商品类别列表
 */
export const fetchGoodsTypeList = (data) => {
  return request({
    url: '/dealer/pzDealerGoodsType/selectDealerGoodsTypeByCondition',
    method: 'post',
    data,
  })
}

/**
 * @description 保存/修改商品类别信息
 * @param {Object} data 请求参数
 * @returns {Promise}
 */
export const saveGoodsType = (data) => {
  return request({
    url: '/dealer/pzDealerGoodsType/saveDealerGoodsType',
    method: 'post',
    data,
  })
}

/**
 * @description 删除商品类别信息
 * @param {string} id 商品类别ID
 * @returns {Promise}
 */
export const deleteGoodsType = (id) => {
  return request({
    url: `/dealer/pzDealerGoodsType/deleteDealerGoodsTypeById?id=${id}`,
    method: 'post',
  })
}

/**
 * @description 获取商品大类树，用于子类绑定大类
 */
export const fetchGoodsTypeTree = () => {
  return request({
    url: '/dealer/pzGoodsType/getGoodsTypeTree',
    method: 'post',
  })
}
/**
 * @description 获取商品入库单据列表
 */
export const fetchGoodsStoreList = (data) => {
  return request({
    url: '/dealer/pzGoodsStoreM/selectGoodsStoreMByCondition',
    method: 'post',
    data,
  })
}

/**
 * @description 保存入库单据
 */
export const saveGoodsStore = (data) => {
  return request({
    url: '/dealer/pzGoodsStoreM/saveGoodsStoreM',
    method: 'post',
    data,
  })
}

/**
 * @description 获取入库单据详情通过id
 */
export const fetchGoodsStoreDetail = (id) => {
  return request({
    url: `/dealer/pzGoodsStoreM/viewGoodsStoreMById?goodsStoreMId=${id}`,
    method: 'post',
  })
}

/**
 * @description 删除入库单据
 */
export const deleteGoodsStore = (id) => {
  return request({
    url: `/dealer/pzGoodsStoreM/deleteGoodsStoreMById?viewGoodsStoreMById=${id}`,
    method: 'post',
  })
}

/**
 * @description 获取商品库存列表
 */
export const fetchDealerGoodsStoreList = (data) => {
  return request({
    url: '/dealer/pzDealerGoodsStore/selectDealerGoodsStoreListByCondition',
    method: 'post',
    data,
  })
}

/**
 * @description 保存/修改商品库存
 */
export const saveDealerGoodsStore = (data) => {
  return request({
    url: '/dealer/pzDealerGoodsStore/saveDealerGoodsStore',
    method: 'post',
    data,
  })
}

/**
 * @description 删除商品库存
 */
export const deleteDealerGoodsStore = (id) => {
  return request({
    url: `/dealer/pzDealerGoodsStore/deleteDealerGoodsStoreById?id=${id}`,
    method: 'post',
  })
}
